package cms.utils;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * MD5加密
 */
public class MD5 {
    /**
     * MD5 加密
     */
    public static String getMD5(String str) {
        String md5Hex = org.apache.commons.codec.digest.DigestUtils.md5Hex(str);
        return md5Hex;
    }

    public static void main(String[] args) {
        //BCrypt密码算法,Bcrypt加密最长为72个字符，超过72字符的部分被截断丢弃了
        PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();

        System.out.println(passwordEncoder.encode(SHA.sha256Hex("123456")));
    }
}
